import rxAjax from '@/assets/js/ajax.js';

//门户定义 api接口
export const InsPortalDefApi = {};

InsPortalDefApi.baseUrl= '/api-portal/portal/core/insPortalDef';

//根据月份日程数据
InsPortalDefApi.getCalendarMonthData =function(calendarValue) {
  let url= InsPortalDefApi.baseUrl + '/getCalendarMonthData?calendarValue='+calendarValue;
  return rxAjax.get(url);
}

//根据月份/日期查询日程数据
InsPortalDefApi.getDataByQueryTypeAndVal =function(parameter) {
  let url= InsPortalDefApi.baseUrl + '/getMonthOrDayData';
  return rxAjax.postJson(url,parameter);
}

//查询列表
InsPortalDefApi.query=function (parameter) {
  let url= InsPortalDefApi.baseUrl + '/query';
  return rxAjax.postJson(url,parameter).then (res => {
    return res.result
  })
}

//根据门户Id查询列表
InsPortalDefApi.getListByPortalId=function (portId) {
  let url= InsPortalDefApi.baseUrl + '/getListByPortalId?portId=' + portId;
  return rxAjax.get(url).then (res => {
    return res.data
  });
}

//保存门户布局列表数据
InsPortalDefApi.saveAll =function(parameter) {
  let url= InsPortalDefApi.baseUrl + '/saveAll';
  return rxAjax.postJson(url,parameter);
}

/**
 *根据栏目ID获取栏目数据
 * @param baseConf
 * @param config
 * @param callback
 */

InsPortalDefApi.getDataByColId=function (colId) {
  let url= InsPortalDefApi.baseUrl + '/getDataByColId?colId=' + colId;
  return rxAjax.get(url).then (res => {
    return res.data
  });
}

/**
 *根据栏目ID以及应用ID获取栏目数据
 * @param baseConf
 * @param config
 * @param callback
 */

InsPortalDefApi.getDataByColIdAndAppId=function (colId,appId) {
    let url= InsPortalDefApi.baseUrl + '/getDataByColIdAndAppId?colId=' + colId + '&appId=' + appId;
    return rxAjax.get(url).then (res => {
        return res.data
    });
}

//根据门户Id查询列表
InsPortalDefApi.getLayoutListByPortalId=function (portalId) {
  let url= InsPortalDefApi.baseUrl + '/getLayoutListByPortalId?portalId='+portalId;
  return rxAjax.get(url).then (res => {
    return res.data
  });
}

//根据门户Key查询列表
InsPortalDefApi.getLayoutListByPortalKey=function (portalKey) {
  let url= InsPortalDefApi.baseUrl + '/getLayoutListByPortalKey?portalKey='+portalKey;
  return rxAjax.get(url).then (res => {
    return res.data
  });
}

//根据当前登录用户获取门户数据
InsPortalDefApi.getLayoutListByLoginUser=function () {
  let url= InsPortalDefApi.baseUrl + '/getLayoutListByLoginUser';
  return rxAjax.get(url).then (res => {
    return res.data
  });
}



//------------------insPortalLayout.js  搬迁过来------

/**
* 获取单记录
* @param pkId
* @returns {*}
*/
InsPortalDefApi.get =function(pkId) {
  let url= InsPortalDefApi.baseUrl + '/get?pkId=' + pkId;
  return rxAjax.get(url);
}

//保存数据
InsPortalDefApi.save =function(parameter) {
  let url= InsPortalDefApi.baseUrl + '/save';
  return rxAjax.postJson(url,parameter);
}

//删除数据
InsPortalDefApi.del =function(parameter) {
  let url= InsPortalDefApi.baseUrl + '/del';
  return rxAjax.postUrl(url,parameter);
}

//根据应用ID获取当前人的门户
InsPortalDefApi.getCurUserPortalByAppId=function(appId) {
    let url= InsPortalDefApi.baseUrl + '/getCurUserPortalByAppId?appId=' + appId;
    return rxAjax.get(url);
}

InsPortalDefApi.update =function(parameter) {
    let url= InsPortalDefApi.baseUrl + '/update';
    return rxAjax.postJson(url,parameter);
}


//保存门户快捷入口
InsPortalDefApi.saveQuickEntrance =function(parameter) {
    let url= '/api-portal/portal/core/portalQuickEntrance/save';
    return rxAjax.postJson(url,parameter);
}

//获取个人门户快捷入口
InsPortalDefApi.getQuickEntrance =function(alias) {
    let url= '/api-portal/portal/core/portalQuickEntrance/getQuickEntrance?alias='+alias;
    return rxAjax.get(url);
}

//查询当前用户的菜单
InsPortalDefApi.getMenusByAppId=function(appId){
    let url ='/api-user/user/org/osUser/getMenusByAppId?appId='+appId;
    return rxAjax.get(url);
}

//删除
InsPortalDefApi.delByAlias =function(alias) {
  let url= '/api-portal/portal/core/portalQuickEntrance/delByAlias?alias='+alias;
  return rxAjax.get(url);
}

//获取页面定制菜单
InsPortalDefApi.getCustomMenus=function(){
  let url ='/api-portal/portal/core/portalChartView/getCustomMenus';
  return rxAjax.get(url);
}

InsPortalDefApi.getChartView=function (alias){
  let url ='/api-portal/portal/core/portalChartView/getChartView?alias='+alias;
  return rxAjax.get(url);
}

InsPortalDefApi.getCustomComponent=function (pageAlias,appId,alias,moduleId){
  let url ='/api-portal/portal/core/portalChartView/getCustomComponent';
  return rxAjax.get(url,{pageAlias:pageAlias,appId:appId,alias:alias,moduleId:moduleId});
}

InsPortalDefApi.addChartView=function (params){
  let url ='/api-portal/portal/core/portalChartView/addChartView';
  return rxAjax.postJson(url,params);
}

InsPortalDefApi.delByAliasChartId=function (alias,chartId){
  let url ='/api-portal/portal/core/portalChartView/delByAliasChartId';
  return rxAjax.get(url,{alias:alias,chartId:chartId});
}

//根据应用ID检查是否有当前人门户
InsPortalDefApi.getNotHomePageByAppIds =function(appIds) {
    let url= InsPortalDefApi.baseUrl + '/getNotHomePageByAppIds?appIds='+appIds;
    return rxAjax.get(url);
}

export  default InsPortalDefApi;

